<?php
namespace app\banquet\model;

use app\BaseModel;
use think\facade\Db;

class PackageGoods extends BaseModel
{
    //定义表名
    protected $name = 'longbing_card_banquet_package_goods';


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 16:00
     * @功能说明:添加
     */
    public function dataAdd($data){

        $data['create_time'] = time();

        $res = $this->insert($data);

        return $res;

    }





    /**
     * @author chenniang
     * @DataTime: 2021-05-11 16:03
     * @功能说明:编辑
     */
    public function dataUpdate($dis,$data){

        $res = $this->where($dis)->update($data);

        return $res;

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 16:04
     * @功能说明:详情
     */
    public function dataInfo($dis){

        $data = $this->where($dis)->find();

        return !empty($data)?$data->toArray():[];

    }


    /**
     * @author chenniang
     * @DataTime: 2021-05-11 16:05
     * @功能说明:
     */
    public function dataList($dis,$page=10){

        $data = $this->where($dis)->order('top desc,id desc')->paginate($page)->toArray();

        return $data;

    }


    /**
     * @author chenniang
     * @DataTime: 2021-12-24 14:55
     * @功能说明:首页的宴席列表
     */
    public function indexSelect($place_id){

        $dis[] = ['b.place_id','in',$place_id];

        $dis[] = ['a.status','=',1];

        $data = $this->alias('a')
                ->join('longbing_card_banquet_place_package b','b.package_id = a.id')
                ->where('a.*')
                ->field('a.*')
                ->order('a.top desc,a.id desc')
                ->limit(4)
                ->select()
                ->toArray();

        return $data;

    }







}